<?php
	$Pg = pg_pconnect ('host=localhost port=5432 user=overwatch password=overwatch dbname=overwatch');
	$Known = pg_fetch_all (pg_query ($Pg, "select * from inbound where seen is true and known is true order by Time desc;"));
	$Unknown = pg_fetch_all (pg_query ($Pg, "select * from inbound where seen is true and known is false;"));
?><html>
	<head>
		<title>overwatch: interesting log lines</title>
		<style type="text/css">
			body {
				margin: 0;
				padding: 0;
			}
			h1 {
				font-family: sans-serif;
				font-size: 1.5em;
			}
			h2 {
				font-family: sans-serif;
				font-size: 1.26em;
			}
			ul {
				padding: 0;
				margin: 0;
				list-style: none;
			}
			li {
				font-family: monospace;
			}
		</style>
		<meta http-equiv="refresh" content="60" />
	</head>
	<body>
		<h1>Overwatch: interesting log lines</h1>

		<h2>Unknown lines</h2>
<?php if (is_array ($Unknown) and count ($Unknown)) { ?>
		<ul>
<?php foreach ($Unknown as $Line) { ?>
			<li>
				<?php echo ($Line ['host']); ?>
				<?php echo ($Line ['facility']); ?>:<?php echo ($Line ['severity']); ?>
				<?php echo ($Line ['tag']); ?><?php echo ($Line ['program']); ?>
				<?php echo ($Line ['message']); ?>
			</li>
<?php } ?>
		</ul>
<?php } else { ?>
		<p>nothing found</p>
<?php } ?>

		<h2>Known lines</h2>
<?php if (is_array ($Known) and count ($Known)) { ?>
		<ul>
<?php foreach ($Known as $Line) { ?>
			<li>
				<?php echo (date ('Y-m-d H:i:s', strtotime ($Line ['time']))); ?>
				<?php echo ($Line ['host']); ?>
				<?php echo ($Line ['tag']); ?>
				<?php echo ($Line ['message']); ?>
			</li>
<?php } ?>
		</ul>
<?php } else { ?>
		<p>nothing found</p>
<?php } ?>
	</body>
</html>